import 'package:bwt_ad_flutter/BwtAdCore.dart';
import 'package:bwt_ad_flutter/ad/loader/BwtAdLoader.dart';
import 'package:bwt_ad_flutter/ad/widget/serviceWidget/BwtServiceAd.dart';
import 'package:bwt_ad_flutter/ad/widget/serviceWidget/BwtServiceAdWidget.dart';

class BwtServiceLoader extends BwtAdLoader<BwtServiceAd> {
  loadAd({
    required String posId,
    required double adWidth,
    required double adHeight,
    bool? showClose = false,
  }) {
    load(
      posId: posId,
      methodName: BwtAdCore.methodLoadServiceAd,
      arguments: {
        BwtAdCore.keyAdWidth: adWidth,
        BwtAdCore.keyAdHeight: adHeight,
        BwtAdCore.keyAdShowClose: showClose
      },
    );
  }

  @override
  onAdLoadCallback(BwtServiceAd bwtAd) {
    // TODO: implement onAdLoadCallback
    bwtAd.serviceAdview = BwtServiceAdWidget(
      bwtServiceAd: bwtAd,
      viewType: BwtAdCore.viewTypeBwtServiceAd,
    );

    return super.onAdLoadCallback(bwtAd);
  }

  @override
  BwtServiceAd createBwtAd(
      {required String adId, required Map<String, dynamic>? arguments}) {
    // TODO: implement createBwtAd
    return BwtServiceAd(
        adId: adId,
        adLoaderId: adLoaderId,
        adWidth: arguments?[BwtAdCore.keyAdWidth] ?? double.infinity,
        adHeight: arguments?[BwtAdCore.keyAdHeight] ?? double.infinity);
  }
}
